package com.example.brazil_project.util;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import jodd.util.Base64;

public class IOUtil {
	
	public static void setStream(){
		String  stream =  "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCACmAJoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD5/oor0fwr4U0jVPDtrdXNn5kz797+a46OwHQ+grajRlWlyxMa1aNGPNI84or2b/hX2g+R532DCbtoJmfk4zx83Pv6ZHqKrt4I0BD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ucYBI5zWnf3WmyPY2d3bXxuo7mKWK1juczL+8ZFlYJJkxjBY5yMdRkEDo6KAOUn1nRHt9GkvrO5Mf2yFNMkmYSiaV0IVlcOwb5WbljyRkZO0mMf8Ipe6RaXL2slvbX0trPHsEkeZXZVh+aM43Aoo4JCgDoCCevooA5PTLbw/ZXTajpelXUzXlwHWePdKhdlkfegZiEXEj/ADAAHzMAndXURMJYUkaJoyyhijgblz2OMjNSUUAfAFfX/wAEv+SQ6F/28f8ApRJXyBX1/wDBL/kkOhf9vH/pRJQB6BRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAHwBX1/8Ev8AkkOhf9vH/pRJRRQB6BQTiiigBM0ZoooEGaM0UUALRRRQMKKKKACkzRRQAuaM0UUAGaTNFFAhaKKKBn//2Q==";
		System.out.println(stream);
		byte [] buffer = Base64.decode(stream);  
		
		try {
			FileOutputStream fos = new FileOutputStream("C:/Users/charlie1/Desktop/zxx.crop_rotation/111.jpg");
			
			//for(int i=0;i<stream.length();i++){
				
			
				//循环读取源文件，每次读取1k大小的字节放入目标文件
				//int temp = Integer.parseInt(stream.substring(i, i+1));		
				
				//System.out.print(temp);
				 

				fos.write(buffer); 
				
			//	}
				


			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String [] args) {
		try {
			
		//	setStream();
//		String a ="";
//		FileInputStream fis = new FileInputStream("C:/Users/charlie1/Desktop/QQ20150720092528.jpg");
//		FileOutputStream fos = new FileOutputStream("C:/Users/charlie1/Desktop/111.jpg");
//		ByteArrayOutputStream baos = new ByteArrayOutputStream();  
//		byte [] buffer = new byte[1024];
//		while(true) {
//		//循环读取源文件，每次读取1k大小的字节放入目标文件
//		int temp = fis.read(buffer, 0, buffer.length);
//		if(temp == -1) break;//读取到文件尾部
//		
//		fos.write(buffer, 0, temp);
//		baos.write(buffer,0,temp);  
//		a  = a+temp;
//		}
//		byte[] data = baos.toByteArray();
//		String file= Base64.encodeToString(data);
//		fis.close();
//		fos.close();
//		System.out.println(file);
			
			
			
			StringToFile(FiletoString("C:/Users/charlie1/Desktop/小美打电话了.doc"),"C:/Users/charlie1/Desktop/xxx.doc");
			
		}
		catch(Exception e) {
		System.out.println(e);
		}
		finally {
		
		
	
		
		}
		}

	
	public static String FiletoString(String filename){
		String file=null;
		try {
			//FileInputStream fis = new FileInputStream("C:/Users/charlie1/Desktop/QQ20150720092528.jpg");
			FileInputStream fis = new FileInputStream(filename);
			ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
			byte [] buffer = new byte[1024];
			while(true) {				
				//循环读取源文件，每次读取1k大小的字节放入目标文件
				int temp = fis.read(buffer, 0, buffer.length);
				if(temp == -1) break;//读取到文件尾部			

				baos.write(buffer,0,temp);  

						
			}
			byte[] data = baos.toByteArray();
		    file= Base64.encodeToString(data);
			fis.close();
			baos.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(file==null){
			return "err";
			
		}
		return file;

	}
	
	public static boolean StringToFile(String fileStream ,String Filename){
		byte [] buffer = Base64.decode(fileStream);  
		if(fileStream.equals("err")){
			return false;
		}
		try {
			//FileOutputStream fos = new FileOutputStream("C:/Users/charlie1/Desktop/zxx.crop_rotation/111.jpg");
			FileOutputStream fos = new FileOutputStream(Filename);
			fos.write(buffer);
			fos.flush();
			fos.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
		
	}
	public static boolean deleteFile(File f){
		// 如果是文件,直接删除
        if (f.isFile()) {
            f.delete();
            return true;
        }
 
        // 如果是文件夹,先遍历删除里面的文件,最后在把本文件夹删除
//        File[] fs = f.listFiles();
//        for (File file : fs) {
//            // 递归调用的目的是，文件夹里可能有子文件夹
//            deleteFile(file);
//        }
 
        // 删除文件夹
       // f.delete();
        return false;
	}
	public static String FiletoString(String filename,boolean isdelete){
		
		String file =FiletoString(filename);
		if(isdelete){
			deleteFile(new File(filename));
		}
		return file;
		
		
	}
}
